﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Forms.Integration;
using System.Windows.Media;
using nVLC.Declarations.Players;
using VideoReflector.Controllers;

namespace VideoReflector.Video
{
    /// <summary>
    /// Static class implementing set up of VLC player display output
    /// </summary>
    public static class VlcDisplayController
    {
        /// <summary>
        /// Create and configure properties on objects required for video preview display
        /// </summary>
        /// <param name="vlcPlayer"> Underlying nVLC player object being used for video playback </param>
        /// <param name="displayContainer"> WPF panel element to contain video preview display </param>
        /// <param name="height"> Pixel height to use for video output </param>
        /// <param name="width"> Pixel width to use for video output </param>
        public static void SetUpDisplay(IVideoPlayer vlcPlayer, Panel displayContainer, int height, int width)
        {
            // nVLC IVideoPlayer needs a Windows Form handle therefore need to host WinForms content
            var displayHost = new WindowsFormsHost();
            // create panel to actually paint video on
            var displayPanel = new System.Windows.Forms.Panel();
            vlcPlayer.WindowHandle = displayPanel.Handle;
            // set UI element properties
            displayContainer.Height = height;
            displayContainer.Width = width;
            displayHost.Margin = new System.Windows.Thickness(0);
            displayHost.ToolTip = "Video display area";
            displayHost.Child = displayPanel;
            displayContainer.Children.Add(displayHost);
        }
    }
}
